build: Use golangci action and make parallel. #3160
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates the GitHub workflow to use the official
golangci-lint
action which has additional caching logic and also creates GitHub annotations for any issues which makes it easier to identify issues versus needing to dig through build logs.It also arranges for the linters to run as a separate job which executes in parallel to the go build and tests.
Since the repository has multiple modules and golangci-lint does not support running all modules in the repository directly, this uses a separate job to resolve the modules dynamically and then feeds those into the separate linter job as a matrix of modules (work directories) so the linters run on all modules in the repo.
In order to avoid running the linters as a part of the normal test job while still allowing developers to invoke all of the tests and linters via the "run_tests.sh" script, this separates the linter logic into a separate "lint.sh" script and conditionally invokes that script only when not running as a GitHub action.
Finally, it pins the dependencies for both the action itself as well as the golangci-lint version by using their respective hashes.